package ch.sv7.tool.dbmanager.db.difference;

import ch.sv7.tool.dbmanager.db.ConstraintSchema;
import ch.sv7.tool.dbmanager.db.TableSchema;

public class ConstraintDefinitionDifference extends AbstractTableDifference {

	private ConstraintSchema actualConstraintSchema;
	private ConstraintSchema expectedConstraintSchema;


	public ConstraintDefinitionDifference(TableSchema expectedTableSchema, TableSchema actualTableSchema, ConstraintSchema actualConstraintSchema, ConstraintSchema expectedConstraintSchema) {
		super(expectedTableSchema, actualTableSchema);
		this.actualConstraintSchema = actualConstraintSchema;
		this.expectedConstraintSchema = expectedConstraintSchema;
	}




	/**
	 * @return the actualConstraintSchema
	 */
	public ConstraintSchema getActualConstraintSchema() {
		return actualConstraintSchema;
	}




	/**
	 * @return the expectedConstraintSchema
	 */
	public ConstraintSchema getExpectedConstraintSchema() {
		return expectedConstraintSchema;
	}




	public String getMessage() {
		return super.getMessage() 
			+ " constraint " 
			+ getActualConstraintSchema().getName() 
			+ " definition: " + getActualConstraintSchema().getDefinition() 
			+ " should be " + getExpectedConstraintSchema().getDefinition();
	}

	public boolean isBlocker() {
		return true;
	}
	
	public String groupByInformation(){
		return "Constraint: " + actualConstraintSchema.getTableSchema().getName() + "." + actualConstraintSchema.getIdentity();
	}
	
}
